Print Source Code

Anyone have luck printing the current DXL under execution? Played with XFLAGS_ and SrcPrint_, but it triggers diagnostic logs.

Yes, I know how to get DXL out of triggers, attrDXL, and layouts, but I'm asking about DXL getting the code for itself.

  • Louie

llandale - Wed Feb 17 12:00:31 EST 2010

Re: Print Source Code
doors36677 - Wed Feb 17 12:31:50 EST 2010

This can be done if you write Assembly code that is initiated by dxl and passes the code by to dxl.

Re: Print Source Code
Mathias Mamsch - Wed Feb 17 13:10:33 EST 2010

doors36677 - Wed Feb 17 12:31:50 EST 2010
This can be done if you write Assembly code that is initiated by dxl and passes the code by to dxl.

Do you have an example how to execute assembly code from dxl? And even if you could, it is hard to get the DXL code that is currently under execution, since with every DOORS version the code is to be found on different positions in memory, you would have to deduce the DXL code by some fix-points, e.g. the DXL stack pointer or something.

I think DOORS uses Yacc to parse the DXL code before execution and will convert it to some kind of "microcode", which is then executed. I played with the _srcprint and XFLAGS options once too and I only got print-outs of the dxl "microcode" but but never the source code. I don't think that you can get the sourcecode from DXL unless you look at the right memory location, but this one is different for every doors executable.

Regards, Mathias

Re: Print Source Code
doors36677 - Wed Feb 17 13:21:03 EST 2010

Mathias Mamsch - Wed Feb 17 13:10:33 EST 2010
Do you have an example how to execute assembly code from dxl? And even if you could, it is hard to get the DXL code that is currently under execution, since with every DOORS version the code is to be found on different positions in memory, you would have to deduce the DXL code by some fix-points, e.g. the DXL stack pointer or something.

I think DOORS uses Yacc to parse the DXL code before execution and will convert it to some kind of "microcode", which is then executed. I played with the _srcprint and XFLAGS options once too and I only got print-outs of the dxl "microcode" but but never the source code. I don't think that you can get the sourcecode from DXL unless you look at the right memory location, but this one is different for every doors executable.

Regards, Mathias

Since I have done the task mentioned, I believe you’re over exagerating the complexity.

Re: Print Source Code
llandale - Wed Feb 17 16:40:36 EST 2010

doors36677 - Wed Feb 17 12:31:50 EST 2010
This can be done if you write Assembly code that is initiated by dxl and passes the code by to dxl.

Have no clue about using Assembly within a DXL script. Anyway, you have some code that resembles this ??:

void FindFatalError()
{  string CurrentCode = GetCurrentCode(MagicDxlSetting3)
   print CurrentCode "\n"
}
FindFatalError()


Which when run from the DXL window, prints this:

 

void FindFatalError()
{  string CurrentCode = GetCurrentCode(MagicDxlSetting3)
   print CurrentCode "\n"
}
FindFatalError()

 

 

 

  • Louie

 

 

Re: Print Source Code
doors36677 - Wed Feb 17 16:54:34 EST 2010

llandale - Wed Feb 17 16:40:36 EST 2010

Have no clue about using Assembly within a DXL script. Anyway, you have some code that resembles this ??:

void FindFatalError()
{  string CurrentCode = GetCurrentCode(MagicDxlSetting3)
   print CurrentCode "\n"
}
FindFatalError()


Which when run from the DXL window, prints this:

 

void FindFatalError()
{  string CurrentCode = GetCurrentCode(MagicDxlSetting3)
   print CurrentCode "\n"
}
FindFatalError()

 

 

 

  • Louie

 

 

The applications doesn't really have to be Assembler, just any application that can make system calls to get the DXL Input window in the dxl editor. This can even be done with ms word and vba. The implmentations is look for the DXL editor, then look for the DXL Input window, then grab the text. After grabbing the text your application can do with it what you want.

But as far as I know there is no undocumented dxl command to grab or print text from the dxl input window.

However, finding the window and grabbing the text is relative easy to do with system calls. Grabbing the window is easy -- but pushing the print button by code is much more complex.

Re: Print Source Code
SystemAdmin - Wed Feb 17 17:43:03 EST 2010

llandale - Wed Feb 17 16:40:36 EST 2010

Have no clue about using Assembly within a DXL script. Anyway, you have some code that resembles this ??:

void FindFatalError()
{  string CurrentCode = GetCurrentCode(MagicDxlSetting3)
   print CurrentCode "\n"
}
FindFatalError()


Which when run from the DXL window, prints this:

 

void FindFatalError()
{  string CurrentCode = GetCurrentCode(MagicDxlSetting3)
   print CurrentCode "\n"
}
FindFatalError()

 

 

 

  • Louie

 

 

1. Instrument your DXL code. For every line of DXL code, insert a line of code that prints it. You could probably write a text editor macro that does this.

2. Use the function "dxlHere()" to print the line numbers, which if you were ambitious, you could automagically transform into the line of code with some other app.

Of course, if you want the lines of code in something more useful than the DXL Interaction window, use IPC or Streams or Files or whatever.

Re: Print Source Code
Mathias Mamsch - Thu Feb 18 15:00:18 EST 2010

doors36677 - Wed Feb 17 13:21:03 EST 2010
Since I have done the task mentioned, I believe you’re over exagerating the complexity.

We might be talking about different things here. I was not talking about reading the dxl source code from the dxl editor. I was talking about a function that will return the dxl source code, that you are currently executing (i.e. the source of the active DXL context) as a string and that will work independent of what kind of DXL code you are executing (e.g. an encrypted DXL, a trigger, an attribute dxl, code started over COM, from the editor, as a batch, etc.) I hope you get the idea.

And if you have a way to "embed" assembly code into DXL and execute it in the DOORS process space, that really would bring some nice extensibility to DOORS. The only way I know of is to put the assembly code into a COM server and call it there. Do you know a way without a COM server?

Regards, Mathias

Re: Print Source Code
llandale - Sun Jun 27 20:56:32 EDT 2010

Ping.

What I really want to do is have a self installing Trigger code, without having to code the body of the trigger inside a string variable, along with all those extra escape characters. Its not practical to have the code issue 'readFile()' to get a copy of itself, since that will require the code to know where itself is deployed, which will indeed be different if sent somewhere else.

That is, I want to write a Trigger DXL with this structure:

void  RunBodyOfTrigger(Trigger tCurr)
{    Object obj = object(tCurr)
        proceed with processing the trigger
} // end BodyOfTrigger()
 
void  DeployTrigger()
{     string  DxlCode = GetTheCurrentDxlCode() // *********
        string  ErrMess = checkDxl(DxlCode)
        if (!null ErrMess)  //
        then display errmess
        else
        {  offer to delete triger, if it exists
           offer to deploy trigger
        }
}
 
// ********* MAIN *********
Trigger tCurr = current
if (!null tCurr)  //-
then RunBodyOfTrigger(tCurr)    // Code running as Trigger
else DeployTrigger()            // code running on demand


I figure that when the function is run from an Include file, it gets the code in that include file only, not in the calling file.

 

 

  • Louie

 

 

Re: Print Source Code
llandale - Thu Nov 18 13:34:37 EST 2010

llandale - Sun Jun 27 20:56:32 EDT 2010

Ping.

What I really want to do is have a self installing Trigger code, without having to code the body of the trigger inside a string variable, along with all those extra escape characters. Its not practical to have the code issue 'readFile()' to get a copy of itself, since that will require the code to know where itself is deployed, which will indeed be different if sent somewhere else.

That is, I want to write a Trigger DXL with this structure:

void  RunBodyOfTrigger(Trigger tCurr)
{    Object obj = object(tCurr)
        proceed with processing the trigger
} // end BodyOfTrigger()
 
void  DeployTrigger()
{     string  DxlCode = GetTheCurrentDxlCode() // *********
        string  ErrMess = checkDxl(DxlCode)
        if (!null ErrMess)  //
        then display errmess
        else
        {  offer to delete triger, if it exists
           offer to deploy trigger
        }
}
 
// ********* MAIN *********
Trigger tCurr = current
if (!null tCurr)  //-
then RunBodyOfTrigger(tCurr)    // Code running as Trigger
else DeployTrigger()            // code running on demand


I figure that when the function is run from an Include file, it gets the code in that include file only, not in the calling file.

 

 

  • Louie

 

 

Ping again. Negative response from IBM 'cannot do that', but they indicated that its undesirable since it may be encrypted; which suggests it can indeed be done. Perhaps Mathias has some clue about this.

But failing to get a copy of the code itself, perhaps I can insert a clever fileName() function allowing the user to browse for some file with the same base name as this script; and have the code remember which one was used last time. This would, I suppose, be reasonably close to self-installing trigger code, allowing me to have a single file for the trigger rather than two.

  • Louie